Repository navigation
feat(vba): dead-code report with Access/VBA-aware exclusions - #349
Merged
Merged
Conversation
Adds `codegraph-vba dead-code [path] [--json] [--limit]` on top of upstream's buildDeadCodeReport, with a VBA layer: - event procedures (event-handler edges, <Control>_<Event>, Form_/Report_ events, Class_Initialize/Terminate, WithEvents handlers) are not dead - Implements members and Dysflow test modules (Test_*.bas) are excluded - public procedures of standard modules go to a separate "public, possibly external" list (a macro or Application.Run may call them) - the mention check is VBA-aware: case-insensitive, ignores comments, the procedure's own body (a Function assigns its own name) and the CodeBehindForm copy, and searches every VBA file for late-bound calls On a 163-file Access corpus it reports 84 dead procedures and 77 public ones, with no edge changed. Closes #344
Review follow-ups: an unreadable VBA file is reported as a warning (unreadableVbaFiles) instead of emptying the dead list; --limit accepts only whole numbers of 1 or more; the summary describes the VBA mention rule; the per-row VBA outcome is explicit; test-module names are matched case-insensitively at a word boundary; CLI tests skip on a stale build. Refs #344
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
Second-review follow-ups: - the VBA mention text is read once per report with its own budget, so it never uses up the shared per-row file cap; skipped files are listed with a reason in vba.unreadableFiles - one identifier index per report replaces the per-row rescan of every VBA file (about 3x faster on a 163-file Access corpus, same rows) - comment blanking follows ' _' line continuation and Rem after ':' - WithEvents handlers are recognised from graph facts, not source reads - TESTAMENTO.bas is not a test module; Test_*.bas and TestHelper.bas are - CodeBehindForm code is kept as mention text when the form has no .cls - docs state the tested contract for unreadable files; CLI tests fail instead of skipping when CI is set Refs #344
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #344.
New command
codegraph-vba dead-code [path] [--json] [--limit N]. It is built on upstream'sbuildDeadCodeReport(which had no CLI; only the viewer used it), with a VBA layer on top.VBA rules
event-handleredges,<Control>_<Event>,Form_/Report_events,Class_Initialize/Terminate,WithEventshandlers taken from the graph;Implementsmembers;Test_*.bas,TestHelper.bas; notTESTAMENTO.bas).Application.Runmay call them.' … _continuation andRemafter:), the procedure's own body (a Function assigns its own name) and theCodeBehindFormcopy when a.clsexists. It searches every VBA file to catch late-bound calls, using one identifier index per report with its own read budget, about 3× faster.Evidence on AGEDYS (163-file Access corpus)
85 dead and 77 public, possibly external (on current main, with #345/#346 merged):
21 tests on a minimal Access fixture, RED→GREEN.
tscis clean, and the VBA and dead-code subsets pass (84 files, 1337 tests). Native review approved after two follow-up rounds; the first spot-check caught an upstream rule that hid almost every VBA Function.Follow-up
#350.